//
//  SchoolDetailBasicTableViewCell.swift
//  HoneyBee
//
//  Created by point on 2018/6/1.
//  Copyright © 2018年 point. All rights reserved.
//

import UIKit

class SchoolDetailBasicTableViewCell: UITableViewCell {
    
    fileprivate lazy var nameLabel =  UILabel.init(UIColor.black, 15, "机构名称")
    
    fileprivate lazy var introductionLabel =  UILabel.init(UIColor.init(hex: "333333")!, 14, "简介简介简介简介简")
    
    fileprivate lazy var appointmentLabel =  UILabel.init(UIColor.init(hex: "f42f2f")!, 12, "275人月月")
    
    // fileprivate lazy var addressView = BasicArrowView(
       //fileprivate lazy var activityLabel =  UILabel.init(UIColor.init(hex: "333333")!, 12, "优惠活动")
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        contentView.backgroundColor = UIColor.white
        self.selectionStyle = .none
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}


// MARK:- 显示数据
extension SchoolDetailBasicTableViewCell {
    func configModel(model:SchoolDetailModel) {
        nameLabel.text = model.name
        introductionLabel.text = model.remark
        appointmentLabel.text = "\(model.appointmentNum )人预约"
        
        if model.basicCellHeight == 0 {
            let size = NSAttributedString.getTextRectSize(text: model.remark as NSString, font: UIFont.systemFont(ofSize: 14), size: CGSize(width: kScreenW - snapKitFit(16), height: 0))
            model.basicCellHeight = size.height + 70
        }
    }
}

// MARK:- UI
extension SchoolDetailBasicTableViewCell {
    fileprivate func setupUI(){
        contentView.addSubview(nameLabel)
        contentView.addSubview(introductionLabel)
        contentView.addSubview(appointmentLabel)
        
        nameLabel.snp.makeConstraints { (make) in
            make.top.equalTo(contentView).jOffset(10)
            make.left.equalTo(contentView).jOffset(8)
        }
        
        introductionLabel.snp.makeConstraints { (make) in
            make.top.equalTo(nameLabel.snp.bottom).jOffset(10)
            make.left.equalTo(contentView).jOffset(8)
            make.right.equalTo(contentView).jInset(8)
        }
        introductionLabel.numberOfLines = 0
       
        
        
        appointmentLabel.snp.makeConstraints { (make) in
            make.right.equalTo(contentView).jInset(8)
            make.top.equalTo(introductionLabel.snp.bottom).jOffset(10)
        }
        
        let oneLineView = UIView()
        contentView.addSubview(oneLineView)
        oneLineView.backgroundColor = UIColor.init(hex: "eeeded")
        oneLineView.snp.makeConstraints { (make) in
            make.height.equalTo(1)
            make.left.right.equalTo(contentView)
            make.bottom.equalTo(contentView)
        }
        
        //        //第2条线
        //        let twoLineView = UIView()
        //        contentView.addSubview(oneLineView)
        //        oneLineView.backgroundColor = UIColor.init(hex: "ffffff")
        //        oneLineView.snp.makeConstraints { (make) in
        //            make.jHeight(5)
        //            make.left.right.equalTo(contentView)
        //            make.top.equalTo(appointmentLabel.snp.bottom).jOffset(12)
        //        }
        
        //        //第3条线
        //        let threeLineView = UIView()
        //        contentView.addSubview(oneLineView)
        //        oneLineView.backgroundColor = UIColor.init(hex: "ffffff")
        //        oneLineView.snp.makeConstraints { (make) in
        //            make.height.equalTo(20)
        //            make.left.right.equalTo(contentView)
        //            make.top.equalTo(appointmentLabel.snp.bottom).jOffset(12)
        //        }
        
        //        addressLabel.snp.makeConstraints { (make) in
        //            make.right.equalTo(contentView).jInset(8)
        //            make.top.equalTo(introductionLabel.snp.bottom).jOffset(10)
        //        }
        
        //        activityLabel.snp.makeConstraints { (make) in
        //            make.jHeight(40)
        //            make.left.equalTo(contentView).jOffset(30)
        //            make.right.equalTo(contentView).jOffset(30)
        //            make.bottom.equalTo(contentView).jOffset(5)
        //        }
        //        activityLabel.backgroundColor = UIColor.white
        
        
        
    }
}
